package cn.edu.zafu.bigdata.cccnnn;
// 父类 Vehicle
class Vehicle {

    public void move() {

        System.out.println("Vehicle is moving");

    }

}
// 子类 Car
class Car extends Vehicle {
    public void move() {

        System.out.println("Car is moving");

    }

}


class Bicycle extends Vehicle {

    public void move() {

        System.out.println("Bicycle is moving");

    }

}

public class TestPolymorphism {

    public static void main(String[] args) {

        // 创建车辆数组

        Vehicle[] vehicles = { new Car(), new Bicycle() };


        for (Vehicle vehicle : vehicles) {

            vehicle.move();  // 输出 "Car is moving" 和 "Bicycle is moving"

        }

    }

}